/*
 * Copyright (C) 2017 Pingan, Inc. All Rights Reserved.
 */

package com.pingan.haofang.searchcloud.index.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.pingan.haofang.searchcloud.common.dto.PageDTO;
import com.pingan.haofang.searchcloud.index.constants.IndexBuildStatus;
import com.pingan.haofang.searchcloud.index.constants.IndexBuildType;
import com.pingan.haofang.searchcloud.index.dto.IndexBuildProgressDTO;
import com.pingan.haofang.searchcloud.index.dto.IndexBuildProgressQuery;
import com.pingan.haofang.searchcloud.index.dto.IndexBuildProgressTopDTO;
import com.pingan.haofang.searchcloud.index.dto.IndexBuildRunningProgressDTO;

/**
 * 索引构建历史SERVICE
 * 
 * @author LUYI374
 * @date May 16, 2017
 * @since 1.0.0
 */
public interface IndexBuildProgressService {

    /**
     * 更新运行时任务状态
     * 
     * @param dto
     */
    public void updateRunningProgress(IndexBuildRunningProgressDTO dto);

    /**
     * 查询
     * 
     * @param query
     * @return
     */
    public PageDTO<IndexBuildProgressDTO> query(IndexBuildProgressQuery query);

    /**
     * 查询
     * 
     * @param id
     * @return
     */
    public Map<String, IndexBuildProgressDTO> query(String projectCode, String indexName, IndexBuildType indexBuildType,
            IndexBuildStatus status);

    /**
     * 查询
     * 
     * @param id
     * @return
     */
    public IndexBuildProgressDTO query(long id);

    /**
     * 查询唯一的progress
     * 
     * @param projectCode
     * @param indexName
     * @param datasourceName
     * @param indexBuildType
     * @return
     */
    public IndexBuildProgressDTO get(String projectCode, String indexName, String datasourceName,
            IndexBuildType indexBuildType);

    /**
     * 刷新运行时状态
     */
    public void flushRunningProgress();

    /**
     * 更新过程
     * 
     * @param dto
     */
    public void updateProgress(IndexBuildProgressDTO dto);

    /**
     * 得到运行时信息
     * 
     * @param id
     * @return
     */
    public IndexBuildRunningProgressDTO getRunningInfo(long id);

    /**
     * 停止进程
     * 
     * @param projectCode
     * @param indexName
     * @param datasourceName
     * @param indexBuildType
     */
    public void stopProgress(String projectCode, String indexName, String datasourceName,
            IndexBuildType indexBuildType);
    
    /**
     * 时间段内状态为status的记录
     */
    List<IndexBuildProgressDTO> queryByStatusAndUpdateTime(Date startTime, Date endTime);

    List<IndexBuildProgressTopDTO> queryIndexBuildProgressCountList(Date fromDate, Date toDate);
}
